<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="html" encoding="UTF-8" />

	<xsl:template match="/">
	<html>
	<head>
		<title>London Pedagogy Planer data</title>
		<h1 style="color: rgb(51, 102, 255);">
  			Module outline
		</h1>
	</head>
	<body>
		<xsl:apply-templates select="/PedagogyPlan/PedagogyPlanModel/ChunkPropertySet"/>
		
		<xsl:apply-templates select="/PedagogyPlan/PedagogyPlanModel"/>
		<xsl:call-template name="TeachingMethod"/>
		<xsl:call-template name="AllocateTable"/>
		
		

	</body>
	</html>
	</xsl:template>
	<xsl:template match="/PedagogyPlan/PedagogyPlanModel">
		
		<table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" width="551">
			<TR>
				<TD>Aims</TD> 
				<TD>	
					<xsl:apply-templates select="/PedagogyPlan/PedagogyPlanModel/ModuleAimSet"></xsl:apply-templates>
				</TD>
			</TR>
			<TR>
				<TD>Topics</TD>
				<TD>
				 <xsl:apply-templates select="/PedagogyPlan/PedagogyPlanModel/TopicSet"></xsl:apply-templates>
				</TD>
			</TR>
			<TR>
				<TD>Learning outscomes</TD>
				<TD>
					<xsl:apply-templates select="/PedagogyPlan/PedagogyPlanModel/LearningOutcomeSet"></xsl:apply-templates>
				</TD>
			</TR>

		</table>

	</xsl:template>
	
	<xsl:template match="/PedagogyPlan/PedagogyPlanModel/ChunkPropertySet">
			<table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" width="551">
				<col width="138"/> <col width="114"/> <col width="102"/> <col width="130"/>
					  <tr valign="top">
    					<td width="138">
      						<p class="western" lang="en-GB">Course name</p>
    					</td>
    					<td colspan="3" width="378">
      						<p class="western" lang="en-GB">
      							<xsl:for-each select="ChunkProperty">
      									<xsl:if test="@name='chunk-name'">	
      										<xsl:apply-templates select="@value"/>
      									</xsl:if>	
      							</xsl:for-each>				
      						</p>
    					</td>
  					</tr> 					
  					<tr valign="top">
    					<td width="138">
      						<p class="western" lang="en-GB">Credit hours</p>
    					</td>
    				<td width="114">
      					<p class="western" lang="en-GB">
      							<xsl:for-each select="ChunkProperty">
      									<xsl:if test="@name='credit-hours'">	
      										<xsl:apply-templates select="@value"/>
      									</xsl:if>	
      							</xsl:for-each>
      					</p>
    				</td>
    				<td width="102">
      					<p class="western" lang="en-GB">
        					Start date
      					</p>
    				</td>
    				<td width="130">
      					<p class="western" lang="en-GB">
        					<br/>
      					</p>
    				</td>
  				</tr>
  				<tr valign="top">
    				<td width="138">
      					<p class="western" lang="en-GB">
        					Contact hours
      					</p>
    				</td>
    				<td width="114">
      					<p class="western" lang="en-GB">
      							<xsl:for-each select="ChunkProperty">
      									<xsl:if test="@name='contact-hours'">	
      										<xsl:apply-templates select="@value"/>
      									</xsl:if>	
      							</xsl:for-each>
      					</p>
    				</td>
    				<td width="102">
      					<p class="western" lang="en-GB">
        					Duration
      					</p>
    				</td>
    				<td width="130">
      					<p class="western" lang="en-GB">
        					<br/>
      					</p>
    				</td>
  				</tr>
  				<tr valign="top">
    				<td width="138">
      					<p class="western" lang="en-GB">
        					Study hours
      					</p>
    				</td>
    				<td width="114">
      					<p class="western" lang="en-GB">
      							<xsl:for-each select="ChunkProperty">
      									<xsl:if test="@name='study-hours'">	
      										<xsl:apply-templates select="@value"/>
      									</xsl:if>	
      							</xsl:for-each>
      					</p>
    				</td>
    				<td width="102">
      					<p class="western" lang="en-GB">
        					Year group
      					</p>
    				</td>
    				<td width="130">
      					<p class="western" lang="en-GB">
        				<br/>
      					</p>
    				</td>
  				</tr>
  				<tr valign="top">
    				<td width="138">
      					<p class="western" lang="en-GB">
        					No of Students
      					</p>
    				</td>
    				<td width="114">
      					<p class="western" lang="en-GB">
      							<xsl:for-each select="ChunkProperty">
      									<xsl:if test="@name='num-students'">	
      										<xsl:apply-templates select="@value"/>
      									</xsl:if>	
      							</xsl:for-each>
      					</p>
    				</td>
    				<td width="102">
      					<p class="western" lang="en-GB">
        					No of staff
      					</p>
    				</td>
    				<td width="130">
      					<p class="western" lang="en-GB">
        				<br />
      					</p>
    				</td>
  				</tr>
  					
				<tbody>
				</tbody>
			</table>
			<br/>
			<br/>	
	</xsl:template>
	
	
	
	<xsl:template match="/PedagogyPlan/PedagogyPlanModel/ModuleAimSet">
		<table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" width="551">
			<xsl:for-each select="ModuleAim">
				<TR>
					<TD>
						<xsl:value-of select="@title"/>	
					</TD>
					<TD>
						<xsl:apply-templates/>
					</TD>
				</TR>
			
			</xsl:for-each>
		</table>
				
	</xsl:template>

	<xsl:template match="/PedagogyPlan/PedagogyPlanModel/TopicSet">
		<table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" width="551">
			<xsl:for-each select="Topic">
				<TR>
					<TD>
						<xsl:value-of select="@title"/>	
					</TD>
					<TD>
						<xsl:apply-templates/>
					</TD>
				</TR>
			
			</xsl:for-each>
		</table>

				
	</xsl:template>

	<xsl:template match="/PedagogyPlan/PedagogyPlanModel/LearningOutcomeSet">
		<table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" width="551">
			<xsl:for-each select="LearningOutcome">
				<TR>
					<TD>
						<xsl:value-of select="@title"/>	
					</TD>
					<TD>
						<xsl:apply-templates/>
					</TD>
				</TR>
			
			</xsl:for-each>
		</table>				
	</xsl:template>
	
	<xsl:template name="TeachingMethod.Row">
			<xsl:param name="sInd"/>
				<!--  The title of the teaching method(Lecture,Tutorial,etc) -->
				<TD><xsl:value-of select="/PedagogyPlan/PedagogyPlanModel/TeachingMethodSet/TeachingMethod[@index=$sInd]/@title" /></TD>
			
				<xsl:variable name="hours"><xsl:value-of select="/PedagogyPlan/PedagogyPlanModel/TeachingMethodHoursAllocationSet/TeachingMethodHoursAllocation[@teachingMethodIndex=$sInd]/@hours" /></xsl:variable>
				
				<TD><xsl:copy-of select="$hours" /></TD>
				<xsl:variable name="hrs"><xsl:value-of select="round(/PedagogyPlan/PedagogyPlanModel/AssociationSet/Association[@destinationIndex='0'][@sourceIndex=$sInd]/@annotation * $hours *100) div 100" /></xsl:variable>
				<xsl:variable name="att"><xsl:value-of select="round(/PedagogyPlan/PedagogyPlanModel/AssociationSet/Association[@destinationIndex='1'][@sourceIndex=$sInd]/@annotation * $hours *100) div 100" /></xsl:variable>
				<xsl:variable name="inq"><xsl:value-of select="round(/PedagogyPlan/PedagogyPlanModel/AssociationSet/Association[@destinationIndex='2'][@sourceIndex=$sInd]/@annotation * $hours *100) div 100" /></xsl:variable>
				<xsl:variable name="dis"><xsl:value-of select="round(/PedagogyPlan/PedagogyPlanModel/AssociationSet/Association[@destinationIndex='3'][@sourceIndex=$sInd]/@annotation * $hours *100) div 100" /></xsl:variable>
				<xsl:variable name="pra"><xsl:value-of select="round(/PedagogyPlan/PedagogyPlanModel/AssociationSet/Association[@destinationIndex='4'][@sourceIndex=$sInd]/@annotation * $hours *100) div 100" /></xsl:variable>
				<xsl:variable name="siz"><xsl:value-of select="/PedagogyPlan/PedagogyPlanModel/TeachingMethodGroupSizeSet/TeachingMethodGroupSize[@teachingMethodIndex=$sInd]/@groupSize" /></xsl:variable>
				
				<!-- Total hours for method -->
				<TD>
					<xsl:if test="contains(number($hrs),'NaN')=false">
					<xsl:value-of select="$hrs"/>
					</xsl:if><BR/>
				</TD>
				<!-- Attention hours for method -->
				<TD>
					<xsl:if test="contains(number($att),'NaN')=false">
					<xsl:value-of select="$att"/>
					</xsl:if><BR/>
				</TD>
				<!-- Inquiry hours for method -->
				<TD>
					<xsl:if test="contains(number($inq),'NaN')=false">
					<xsl:value-of select="$inq"/>
					</xsl:if><BR/>
				</TD>
				<!-- Discussion hours for method -->
				<TD>
					<xsl:if test="contains(number($dis),'NaN')=false">
					<xsl:value-of select="$dis"/>
					</xsl:if><BR/>
				</TD>
				<!-- Practice hours for method -->
				<TD>
					<xsl:if test="contains(number($pra),'NaN')=false">
					<xsl:value-of select="$pra"/>
					</xsl:if><BR/>
				</TD>				
				<!-- Group size -->
				<TD>
					<xsl:if test="contains(number($siz),'NaN')=false">
					<xsl:value-of select="$siz"/>
					</xsl:if><BR/>
				</TD>				

				

			
	</xsl:template>
	
	
	<xsl:template name="TeachingMethod" match="/PedagogyPlan/PedagogyPlanModel/AssociationSet">
		<br/>
		<table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" width="551">
			<TR>
				<TD>Teaching Method</TD>
				<TD>Hours</TD>
				<TD>Attention</TD>
				<TD>Inquiry</TD>
				<TD>Discussion</TD>
				<TD>Practice</TD>
				<TD>Production</TD>
				<TD>Group Size</TD>				
			</TR>
			
			<!--  Lectures -->	
			<TR>
			<xsl:call-template name="TeachingMethod.Row">
				<xsl:with-param name="sInd">0</xsl:with-param>
			</xsl:call-template>
			</TR>
			<!--  Tutorials -->	
			<TR>
			<xsl:call-template name="TeachingMethod.Row">
				<xsl:with-param name="sInd">1</xsl:with-param>
			</xsl:call-template>
			</TR>
			<!--  Study guides -->	
			<TR>
			<xsl:call-template name="TeachingMethod.Row">
				<xsl:with-param name="sInd">2</xsl:with-param>
			</xsl:call-template>
			</TR>
			<!--  Set Reading -->	
			<TR>
			<xsl:call-template name="TeachingMethod.Row">
				<xsl:with-param name="sInd">3</xsl:with-param>
			</xsl:call-template>
			</TR>
			<!--  Online-->	
			<TR>
			<xsl:call-template name="TeachingMethod.Row">
				<xsl:with-param name="sInd">4</xsl:with-param>
			</xsl:call-template>
			</TR>
			<!--  Tutor-->	
			<TR>
			<xsl:call-template name="TeachingMethod.Row">
				<xsl:with-param name="sInd">5</xsl:with-param>
			</xsl:call-template>
			</TR>
		</table>
	
	</xsl:template>
	<xsl:template name="AllocateTable">
		<BR/>
	
		<table border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" width="551">
			<TR>
				<TD><BR/></TD><TD>Week1</TD><TD>Week2</TD><TD>Week3</TD><TD>Week4</TD><TD>Week5</TD><TD>Week6</TD><TD>Week7</TD><TD>Week8</TD><TD>Week9</TD><TD>Week10</TD>
			</TR>
			<xsl:for-each select="/PedagogyPlan/PedagogyPlanModel/TopicSet/Topic"><xsl:variable name="ind"><xsl:value-of select="@index"/></xsl:variable>
				<TR>
					<TD><xsl:value-of select="@title"/></TD>
					<xsl:choose>
						<xsl:when test="@index=/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation/@index">
							<xsl:choose>
								<xsl:when test="/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation[@index = $ind]/@slot=0"><TD BGCOLOR="#00AAAA"><BR/></TD></xsl:when>
								<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
							</xsl:choose>
						</xsl:when>
						<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
					</xsl:choose>

					<xsl:choose>
						<xsl:when test="@index=/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation/@index">
							<xsl:choose>
								<xsl:when test="/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation[@index = $ind]/@slot=1"><TD BGCOLOR="#00AAAA"><BR/></TD></xsl:when>
								<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
							</xsl:choose>
						</xsl:when>
						<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
					</xsl:choose>

					<xsl:choose>
						<xsl:when test="@index=/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation/@index">
							<xsl:choose>
								<xsl:when test="/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation[@index = $ind]/@slot=2"><TD BGCOLOR="#00AAAA"><BR/></TD></xsl:when>
								<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
							</xsl:choose>
						</xsl:when>
						<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
					</xsl:choose>
					
					<xsl:choose>
						<xsl:when test="@index=/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation/@index">
							<xsl:choose>
								<xsl:when test="/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation[@index = $ind]/@slot=3"><TD BGCOLOR="#00AAAA"><BR/></TD></xsl:when>
								<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
							</xsl:choose>
						</xsl:when>
						<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
					</xsl:choose>
					
					<xsl:choose>
						<xsl:when test="@index=/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation/@index">
							<xsl:choose>
								<xsl:when test="/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation[@index = $ind]/@slot=4"><TD BGCOLOR="#00AAAA"><BR/></TD></xsl:when>

								<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
							</xsl:choose>
						</xsl:when>
						<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
					</xsl:choose>
					
					
					<xsl:choose>
						<xsl:when test="@index=/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation/@index">
							<xsl:choose>
								<xsl:when test="/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation[@index = $ind]/@slot=5"><TD BGCOLOR="#00AAAA"><BR/></TD></xsl:when>
								<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
							</xsl:choose>
						</xsl:when>
						<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
					</xsl:choose>
					
					
					<xsl:choose>
						<xsl:when test="@index=/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation/@index">
							<xsl:choose>
								<xsl:when test="/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation[@index = $ind]/@slot=6"><TD BGCOLOR="#00AAAA"><BR/></TD></xsl:when>
								<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
							</xsl:choose>
						</xsl:when>
						<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
					</xsl:choose>
					
					
					<xsl:choose>
						<xsl:when test="@index=/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation/@index">
							<xsl:choose>
								<xsl:when test="/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation[@index = $ind]/@slot=7"><TD BGCOLOR="#00AAAA"><BR/></TD></xsl:when>
								<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
							</xsl:choose>
						</xsl:when>
						<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
					</xsl:choose>
					
					
					
					<xsl:choose>
						<xsl:when test="@index=/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation/@index">
							<xsl:choose>
								<xsl:when test="/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation[@index = $ind]/@slot=8"><TD BGCOLOR="#00AAAA"><BR/></TD></xsl:when>
								<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
							</xsl:choose>
						</xsl:when>
						<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
					</xsl:choose>					
					<xsl:choose>
						<xsl:when test="@index=/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation/@index">
							<xsl:choose>
								<xsl:when test="/PedagogyPlan/PedagogyPlanModel/AllocationSet/Allocation[@index = $ind]/@slot=9"><TD BGCOLOR="#00AAAA"><BR/></TD></xsl:when>
								<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
							</xsl:choose>
						</xsl:when>
						<xsl:otherwise><TD><BR/></TD></xsl:otherwise>
					</xsl:choose>
				</TR>
			</xsl:for-each>

		</table>
	</xsl:template>



</xsl:stylesheet>
